Skip to content

Fix that partial insert with nulls may result in negative inserted point count#17640

Merged
jt2594838 merged 2 commits into
apache:masterfrom
Caideyipi:fix_partial_insert_negative_points
May 13, 2026
Merged

Fix that partial insert with nulls may result in negative inserted point count#17640
jt2594838 merged 2 commits into
apache:masterfrom
Caideyipi:fix_partial_insert_negative_points

Conversation

@jt2594838
Copy link
Copy Markdown
Contributor

@jt2594838 jt2594838 commented May 12, 2026

Summary

When a partial insert has failed measurements (\measurements[i] == null), the \pointsInserted\ counter could go negative in two paths:

  1. **\AbstractMemTable.insertAlignedRow**: a failed measurement slot has both \measurements[i] == null\ and values[i] == null. The old guard \if (values[i] == null)\ did not check \measurements[i]\ first, so the null value was counted as a
    ullPoint\ and subtracted from the total, producing a negative result.

  2. **\AbstractMemTable.computeTabletNullPointsNumber**: failed measurement columns were not skipped before inspecting their bitmaps, so any marked bits in a failed column were incorrectly counted as null points.

Changes

  • **\InsertNode.java**: add \isMeasurementFailed(int index)\ helper that returns \measurements[index] == null.
  • **\AbstractMemTable.java**:
    • \insertAlignedRow: change guard to \measurements[i] != null && values[i] == null\ so failed measurements are excluded from
      ullPointsNumber.
    • \computeTabletNullPointsNumber: skip columns where \isMeasurementFailed(i)\ is true before counting bitmap marks.

Tests

  • **\InsertNodeIsMeasurementFailedTest**: unit tests for the new \isMeasurementFailed\ method on both \InsertRowNode\ and \InsertTabletNode, covering no-failure, single failure, all-failed, and idempotent mark cases.
  • **\AbstractMemTablePartialInsertTest**: unit tests for \insertAlignedRow\ and \insertTablet\ with precise \AssertEquals\ assertions on \pointsInserted\ and \ otalPointsNum, covering all combinations of failed measurements and null bitmaps.

@jt2594838 jt2594838 merged commit 4b2946e into apache:master May 13, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant